# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-pycrtsh
pkgname=('python2-pycrtsh' 'python-pycrtsh')
_pkgname=pycrtsh
pkgver=66.b94163a
pkgrel=1
pkgdesc='Python library to request crt.sh certificate information.'
arch=('any')
url='https://pypi.org/project/pycrtsh/#files'
license=('APACHE')
makedepends=('git' 'python2-setuptools' 'python-setuptools')
source=("git+https://github.com/Te-k/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cp -a "$_pkgname"{,-2}
}

build() {
  cd "$_pkgname-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname"

  python setup.py build
}

package_python2-pycrtsh() {
  depends=('python2' 'python2-beautifulsoup4' 'python2-dateutil' 'python2-lxml'
           'python2-requests')

  cd "$_pkgname-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build

  mv "$pkgdir/usr/bin/certsh" "$pkgdir/usr/bin/certsh2"
}

package_python-pycrtsh() {
  depends=('python' 'python-beautifulsoup4' 'python-dateutil' 'python-lxml'
           'python-requests')

  cd $_pkgname

  python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

